package com.ddd.test.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ddd.test.dto.query.SalesOrdersDTO;
import com.ddd.test.result.Result;
import com.ddd.test.service.OrderService;

@RestController
@RequestMapping("/order")
public class OrderRestService {
	
	   @Autowired
	   OrderService orderService;

	/**
	   * 按用户查询订单详情和用户详情
	   *
	   * @return Result<SalesOrdersDTO>
	   */

	  @RequestMapping(value = "/queryOrdersBySalesCode", method = {RequestMethod.POST})
	  Result<SalesOrdersDTO> queryOrdersBySalesCode(@RequestBody String salesCode) {
		  JSONObject object= JSON.parseObject(salesCode);
		  return orderService.queryOrdersBySalesCode(object.getString("salesCode"));
	  };
	  
	  @RequestMapping(value = "/queryOrdersBySalesCode1", method = {RequestMethod.POST})
	  Result<String> queryOrdersBySalesCode1(@RequestBody String salesCode) {
		  JSONObject object= JSON.parseObject(salesCode);
		  return orderService.queryOrdersBySalesCode1(object.getString("salesCode"));
	  };
	  
}
